﻿#ifndef SOUNDTOUCHEX_H
#define SOUNDTOUCHEX_H

#include <QDebug>
#include "SoundTouch.h"
#include "STTypes.h"
#include "ringbuffer.h"

#define MaxTouchBufferSize 8192

//变声、变速处理类
class SoundTouchEx
{
public:
    SoundTouchEx();
    ~SoundTouchEx();

    //设置音频采样率、通道、变速、变调
    void setProcessParm(int sampleRate, int channel, int bytePerSample, double tempo = 1.0, double pitch = 1.0);

    //处理一帧原始音频数据
    void processAudioData(char *inPcmBuf, int inPcmBufSize);
    //处理结束冲刷下剩余数据
    void flushLastData();

private:
    soundtouch::SAMPLETYPE touchBuffer[MaxTouchBufferSize];
    soundtouch::SoundTouch soundTouch;

    //音频参数
    int sampleRate;
    int channel;
    int bytePerSample;

    //最大接收sample数量
    int maxRecv;

public:
    //处理后的缓冲区
    RingBuffer buffer;
};

#endif // SOUNDTOUCHEX_H
